* Replication Code for Thomsen and King - Gendered Pipeline to Power

* Datasets:
* 1_StateLegislators (Thomsen 2017)
* 2_Newspapers (King 2017)
* 3_LawyerDonors (Bonica and Sen 2017)
* 4_Occupations (NCSL)
* 5_2018 (Project Vote Smart)

***Table 1: Rates of Entry and Number of Potential Candidates
*(1) State Legislators
use "1_StateLegislators.dta", clear

ttest run_cong, by(female)
bysort female: tab run_cong

ttest run_cong if rep==0, by(female)
bysort female: tab run_cong if rep==0

ttest run_cong if rep==1, by(female)
bysort female: tab run_cong if rep==1

*(2) Named in Papers
use "2_Newspapers.dta", clear

ttest declared, by(female)
bysort female: tab declared

ttest declared if republican==0, by(female)
bysort female: tab declared if republican==0

ttest declared if republican==1, by(female)
bysort female: tab declared if republican==1

*(3) Lawyer-Donors
use "3_LawyerDonors.dta", clear

ttest runoffice, by(female)
bysort female1: tab runoffice

ttest runoffice if rep==0, by(female)
bysort female1: tab runoffice if rep==0

ttest runoffice if rep==1, by(female)
bysort female: tab runoffice if rep==1

*Lawyer-Donors By Age Cohort (those in first 23 years of career vs. longer)
sum lyear if female==1
ttest runoffice if female==1, by(over23)
ttest runoffice if over23==1, by(female)
ttest runoffice if over23==0, by(female)

bysort over23: tab female if rep==0
bysort over23: tab female if rep==1

***Figure 1: Women Have to Be More Likely to Run than Men
use "Table1Means.dta", clear

graph bar (mean) RateofRunning if Sample=="State Legislators", over(Label) over(Republican) blabel(total, size(small)) ///
	asyvars bar(1, color(gs13)) bar(2, color(gs7)) bar(3, color(gs4)) legend(cols(1)) legend(size(medsmall))  ///
	ytitle("Rate of Candidate Entry (%)", size(medium)) graphregion(color(white)) plotregion(lcolor(black)) 

graph bar (mean) RateofRunning if Sample=="Lawyer-Donors", over(Label) over(Republican) blabel(total, size(small) format(%03.1f)) ///
	asyvars bar(1, color(gs13)) bar(2, color(gs7)) bar(3, color(gs4)) legend(cols(1)) legend(size(medsmall)) ///
	ytitle("Rate of Candidate Entry (%)", size(medium)) graphregion(color(white)) plotregion(lcolor(black)) ///
	ylabel(0(2)10)
	
***Table 2: How Rates of Entry and Supply Impact the Number of Women Candidates
*Calculated with Values from Table 1

***Table 3: Occupational Pathways to Office and Women's Representation
use "4_Occupations.dta", clear
reg pctwomen Attorney Business Educator Homemaker Medical Agriculture i.year i.state2 

***Figure 2: Lawyer-Legislators (Educator-Legislators) are Negatively (Positively) Associated with Women’s Representation
reg pctwomen Attorney Business Educator Homemaker Medical Agriculture i.year i.state2 
margins, atmeans at(Attorney=(1(1)39))
marginsplot, xlabel(5(10)35) scheme(s1manual) ///
	recast(line) recastci(rarea) ylabel(12(4)28) ytitle("Women State Legislators (%)", size(medium)) ///
	xtitle("Percent Lawyers", size(medium)) title(" ") 

reg pctwomen Attorney Business Educator Homemaker Medical Agriculture i.year i.state2 
margins, atmeans at(Educator=(0(1)20))
marginsplot, xlabel(0(5)20) scheme(s1manual) ///
	recast(line) recastci(rarea) ylabel(12(4)28) ytitle("Women State Legislators (%)", size(medium)) ///
	xtitle("Percent Educators", size(medium)) title(" ") 

reg pctwomen Attorney Business Educator Homemaker Medical Agriculture i.year i.state2 
margins, atmeans at(Attorney=(1 39))
margins, atmeans at(Educator=(0 20))

***Occupations (2018 vs. 2010-16)
use "5_2018.dta", clear

*2018
tab occ_Educ if female==1 & party=="Democrat" & year==2018
tab occ_Law if female==1 & party=="Democrat" & year==2018
tab occ_Business if female==1 & party=="Democrat" & year==2018
tab occ_Medical if female==1 & party=="Democrat" & year==2018

*2010-2016
tab occ_Educ if female==1 & party=="Democrat" & year!=2018
tab occ_Law if female==1 & party=="Democrat" & year!=2018
tab occ_Business if female==1 & party=="Democrat" & year!=2018
tab occ_Medical if female==1 & party=="Democrat" & year!=2018

*Likelihood of female lawyers being elected
ttest elected if female==1 & year==2018, by(occ_Law)
ttest elected if female==1 & year!=2018, by(occ_Law)

*Occupational backgrounds of female winners
ttest occ_Educ if female==1 & elected==1 & party=="Democrat", by(dummy2018)
ttest occ_Medical if female==1 & elected==1 & party=="Democrat", by(dummy2018)
ttest occ_Law if female==1 & elected==1 & party=="Democrat", by(dummy2018)
ttest occ_Business if female==1 & elected==1 & party=="Democrat", by(dummy2018)

*Women's advantage in 2018
ttest elected if year==2018 & party=="Democrat" & occ_Law==1, by(female)
ttest elected if female==1 & party=="Democrat" & occ_Law==1, by(dummy2018)

******************************************************************
******************************************************************
***Appendix

* Additional Datasets:
* Appendix_D1
* Appendix_D2
* Appendix_D3

***Appendix B: The Relationship Between Gender and the Decision to Run for Office

***Table B1: The Decision to Run for Office Across State Legislators, Potential Senate Candidates, and Lawyer-Donors
*(1) State Legislators (Office Sought: US House)
use "1_StateLegislators.dta", clear
logit run_cong female moderate experience republican Probability_of_Electing_a_Woman openseat ///
	pvi_partyofprimary c.total_primary_pool##c.total_primary_pool i.year i.state2, robust cluster(bonica_rid)

*(2) Named in Papers (Office Sought: US Senate)
use "2_Newspapers.dta", clear
logit declared female moderate experience republican openseat pvi_partyofprimary c.total_primary_pool##c.total_primary_pool ///
	median_income pct_urban pct_black pct_college i.year i.state2, cluster(nameabbr)

*(3) Lawyer-Donors (Office Sought: State or Federal Office)
use "3_LawyerDonors.dta", clear
logit runoffice female1 moderate lyear rep avgprobwoman top14 nottop100 gov prosecutororda i.state2  

*(4) Lawyer-Donors (Office Sought: State)
logit runstate female1 moderate lyear rep avgprobwoman top14 nottop100 gov prosecutororda i.state2  

*(5) Lawyer-Donors (Office Sought: Federal)
logit runfederal female1 moderate lyear rep avgprobwoman top14 nottop100 gov prosecutororda i.state2  

***Appendix C: Splitting the Samples by Party, Adding Interaction Terms, and Omitting Ideology 

***Table C1: The Decision to Run for Office (Republicans)
*(1) State Legislators (Office Sought: US House)
use "1_StateLegislators.dta", clear
logit run_cong female moderate experience Probability_of_Electing_a_Woman openseat ///
	pvi_partyofprimary c.total_primary_pool##c.total_primary_pool i.year i.state2 if rep==1, robust cluster(bonica_rid)

*(2) Named in Papers (Office Sought: US Senate)
use "2_Newspapers.dta", clear
logit declared female moderate experience openseat pvi_partyofprimary c.total_primary_pool##c.total_primary_pool ///
	median_income pct_urban pct_black pct_college i.year i.state2 if republican==1, cluster(nameabbr)
	
*(3) Lawyer-Donors (Office Sought: State or Federal Office)
use "3_LawyerDonors.dta", clear
logit runoffice female1 moderate lyear avgprobwoman top14 nottop100 gov prosecutororda i.state2 if rep==1

*(4) Lawyer-Donors (Office Sought: State)
logit runstate female1 moderate lyear avgprobwoman top14 nottop100 gov prosecutororda i.state2 if rep==1

*(5) Lawyer-Donors (Office Sought: Federal)
logit runfederal female1 moderate lyear avgprobwoman top14 nottop100 gov prosecutororda i.state2 if rep==1

***Table C2: The Decision to Run for Office (Democrats)
*(1) State Legislators (Office Sought: US House)
use "1_StateLegislators.dta", clear
logit run_cong female moderate experience Probability_of_Electing_a_Woman openseat ///
	pvi_partyofprimary c.total_primary_pool##c.total_primary_pool i.year i.state2 if rep==0, robust cluster(bonica_rid)
	
*(2) Named in Papers (Office Sought: US Senate)
use "2_Newspapers.dta", clear
logit declared female moderate experience openseat pvi_partyofprimary c.total_primary_pool##c.total_primary_pool ///
	median_income pct_urban pct_black pct_college i.year i.state2 if republican==0, cluster(nameabbr)
	
*(3) Lawyer-Donors (Office Sought: State or Federal Office)
use "3_LawyerDonors.dta", clear
logit runoffice female1 moderate lyear avgprobwoman top14 nottop100 gov prosecutororda i.state2 if rep==0

*(4) Lawyer-Donors (Office Sought: State)
logit runstate female1 moderate lyear avgprobwoman top14 nottop100 gov prosecutororda i.state2 if rep==0

*(5) Lawyer-Donors (Office Sought: Federal)
logit runfederal female1 moderate lyear avgprobwoman top14 nottop100 gov prosecutororda i.state2 if rep==0

***Table C3: The Decision to Run (With Interactions) 
*(1) State Legislators (Office Sought: US House)
use "1_StateLegislators.dta", clear
logit run_cong i.female##c.moderate i.female##c.experience i.female##i.republican i.female##c.Probability_of_Electing_a_Woman i.female##i.openseat ///
	i.female##c.pvi_partyofprimary i.female##c.total_primary_pool##c.total_primary_pool i.year i.state2, robust cluster(bonica_rid)
	
*(2) Named in Papers (Office Sought: US Senate)
use "2_Newspapers.dta", clear
logit declared i.female##c.moderate i.female##c.experience i.female##i.republican i.female##i.openseat i.female##c.pvi_partyofprimary  	///
	i.female##c.total_primary_pool##c.total_primary_pool i.female##c.median_income i.female##c.pct_urban i.female##c.pct_black i.female##c.pct_college i.year i.state2, cluster(nameabbr)
	
***Table C4: The Decision to Run for Office (With Interactions)
*(3) Lawyer-Donors (Office Sought: State or Federal Office)
use "3_LawyerDonors.dta", clear
logit runoffice i.female1 i.female1##c.moderate i.female1##c.lyear i.female1##i.rep i.female1##c.avgprobwoman i.female1##i.top14 i.female1##i.nottop100 ///
	i.female1##i.gov i.female1##i.prosecutororda i.state2
	
*(4) Lawyer-Donors (Office Sought: State)
logit runstate i.female1 i.female1##c.moderate i.female1##c.lyear i.female1##i.rep i.female1##c.avgprobwoman i.female1##i.top14 i.female1##i.nottop100 ///
	i.female1##i.gov i.female1##i.prosecutororda i.state2
	
*(5) Lawyer-Donors (Office Sought: Federal)
logit runfederal i.female1 i.female1##c.moderate i.female1##c.lyear i.female1##i.rep i.female1##c.avgprobwoman i.female1##i.top14 i.female1##i.nottop100 ///
	i.female1##i.gov i.female1##i.prosecutororda i.state2
	
***Table C5: The Decision to Run (Without Ideology)
*(1) State Legislators (Office Sought: US House)
use "1_StateLegislators.dta", clear
logit run_cong female experience republican Probability_of_Electing_a_Woman openseat ///
	pvi_partyofprimary c.total_primary_pool##c.total_primary_pool i.year i.state2, robust cluster(bonica_rid)
	
*(2) Named in Papers (Office Sought: US Senate)
use "2_Newspapers.dta", clear
logit declared female experience republican openseat pvi_partyofprimary c.total_primary_pool##c.total_primary_pool  ///
	median_income pct_urban pct_black pct_college i.year i.state2, cluster(nameabbr)
	
*(3) Lawyer-Donors (Office Sought: State or Federal Office)
use "3_LawyerDonors.dta", clear
logit runoffice female1 lyear rep avgprobwoman top14 nottop100 gov prosecutororda i.state2

*(4) Lawyer-Donors (Office Sought: State)
logit runstate female1 lyear rep avgprobwoman top14 nottop100 gov prosecutororda i.state2 

*(5) Lawyer-Donors (Office Sought: Federal)
logit runfederal female1 lyear rep avgprobwoman top14 nottop100 gov prosecutororda i.state2 

***Table C6: Coefficients on Women-Friendly Variables Not Presented in Text (Potential Senate Candidates)
*The coefficients are provided above; they were not presented in the tables due to space constraints.

***Appendix D: Leveraging State-Level Differences in Female Lawyer-Donors

***Table D1: Relationship Between Proportion of Female Lawyer-Donors, Female State Legislators, and Female State and Federal Candidates
*(1) State Legislative Candidates, Proportion Female
use "Appendix_D1.dta", clear
reg proportionfemalecand meanfemale genderdiffrunstoffice
margins, atmeans at(meanfemale=(0.07 0.33))

*(2) US House Candidates, Proportion Female
use "Appendix_D2.dta"
reg proportionfemalecand meanfemale genderdiffrunfedoffice
margins, atmeans at(meanfemale=(0.07 0.33))

***Figures D1 and D2
use "Appendix_D1.dta", clear
reg proportionfemalecand meanfemale genderdiffrunstoffice
margins, atmeans at(meanfemale=(0.047(0.01)0.347))
marginsplot, scheme(s1manual) recast(line) recastci(rarea) plotregion(color(white)) plotregion(lcolor(black)) graphregion(color(white)) ///
	xscale(range(0.05 0.35)) ytitle("State Legislative Candidates," "Proportion Female") ///
	xtitle("Lawyer-Donors, Proportion Female") xlabel(0.05(0.10)0.35) title("")

use "Appendix_D2.dta"
reg proportionfemalecand meanfemale genderdiffrunfedoffice  
margins, atmeans at(meanfemale=(0.047(0.01)0.347))
marginsplot, scheme(s1manual) recast(line) recastci(rarea) plotregion(color(white)) plotregion(lcolor(black)) graphregion(color(white)) ///
	yscale(range(0.1 0.4)) ylabel(0.1(0.10)0.4) xscale(range(0.05 0.35)) ytitle("Congressional Candidates," "Proportion Female") ///
	xtitle("Lawyer-Donors, Proportion Female") xlabel(0.05(0.10)0.35) title("")
	
*(3) US House Candidates, Proportion Female
use "Appendix_D3.dta", clear
reg pctwomencongcands pctwomenstleg10 i.year

***End of do file
